﻿package com.uprr.app.tnm.command
{
    import com.uprr.app.tnm.delegate.IItemFactory;
    import com.uprr.app.tnm.delegate.ItemFactory;
    import com.uprr.app.tnm.events.CentralDispatcher;
    import com.uprr.app.tnm.events.FooEvent;
    import com.uprr.app.tnm.model.Model;
    
    public class FooCommand
    {
        [Bindable]
        public var itemFactory : IItemFactory;
        
        public function FooCommand()
        {
            CentralDispatcher.instance.addEventListener( FooEvent.TYPE, fooHandler );
        }
        
        private function fooHandler( event : FooEvent ) : void
        {
            doFoo(event.col1, event.col2);
        }
        
        private function doFoo(
            val1 : String,
            val2 : String
        ) : void
        {
           trace ("inser a new record");
		   Model.instance.arrcol.addItem( itemFactory.createItem(val1, val2));
        }

    }
}